import { setItem, getItem, removeItem } from '@/utils/storage'
const state = {
  stateTagList: getItem('storeState') || [
    {
      path: '/home',
      meta: {
        title: '首页',
      },
      name: 'home',
    },
  ],
}
const mutations = {
  SELECT_TAGS(state, data) {
    let result = state.stateTagList.some((item) => item.path === data.path)
    result === false ? state.stateTagList.push(data) : ''
    setItem('storeState', state.stateTagList)
  },
  // 关闭标签
  CLOSE_TAGS(state, data) {
    let result = state.stateTagList.findIndex((item) => item.path === data.path)
    state.stateTagList.splice(result, 1)
    setItem('storeState', state.stateTagList)
  },
}
const actions = {}

export default {
  namespaced: true,
  state,
  mutations,
  actions,
}
